module MapDemTings
  class InputMapper

    # Simple mapper, can be used like a proc or lambda.
    #
    # Example
    #
    # def mapper
    #   @mapper ||= MapDemTings::InputMapper.new do |input|
    #     Array.wrap( wrap_params[input.to_s] )
    #   end
    # end
    #
    # def author
    #   mapper.map(:author)
    # end
    #
    # This simplifies methods below, but does not cut down
    # on the number of repeats.
    #
    # def author
    #   Array.wrap( wrap_params["author"] )
    # end

    def initialize(&block)
      @block = block
    end

    def map(name)
      @block.call(name)
    end

  end
end
